﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class mesas_lista : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Administrador user = (Administrador)this.Session["Administrador"];
        if (user == null)
        {
            Response.Redirect("../noEstaLogeado.aspx", true);
        }
        ArrayList l = GestionMesas.getInstance().getMesas();
        if (l.Count == 0)
        {
            GestionMesas.getInstance().cargarMesas();
            l = GestionMesas.getInstance().getMesas();
            //Label1.Text = "Se han cargado " + l.Count + " mesas";
        }
        else
        {
            //Label1.Text = "Ya existen mesas en memoria, no se carga ninguna";
        }
        
        String texto = "<table border='0' style='color:#333333;border-collapse:collapse;'><tr style='color:White;background-color:#507CD1;font-weight:bold;'><th scope='col'>IdMesa</th><th scope='col'>Juego</th><th scope='col'>Sitios libres</th></tr>";
        ArrayList lista=GestionMesas.getInstance().getMesas();
        int i=0;
        foreach (MesaBeans m in lista)
        {
            if (i % 2 == 0)
            {
                texto += "<tr style='background-color:#EFF3FB;'><td>" + m.getIdMesa() + "</td><td>" + m.getNombreJuego() + "</td><td>" + m.sitiosLibres() + "</td></tr>";
            }
            else
            {
                texto += "<tr style='background-color:White;'><td>" + m.getIdMesa() + "</td><td>" + m.getNombreJuego() + "</td><td>" + m.sitiosLibres() + "</td></tr>";
            }
            i++;
        }
        texto += "</table>";
        Label1.Text = texto;
    }
}
